<style>
    #formorder{padding: 10px 5px 10px 5px;}
    #formorder input,#formorder select{margin: 5px auto;width: 100px;}#formorder select{padding: 3px 0;}
    #formorder button{
        background: #5bc0de;color: #fff;border: 1px solid transparent;border-radius: 3px;
    }
    
    .page{border-top: 1px solid #E0E0E0;padding: 5px;}
    .page .page_count{padding-top: 5px;}
    .page .page_count label{display: inline-block;line-height: 30px;font-weight: normal;float: left;}
    .page .page_count .paginate_button{
        margin: 0 5px;
        float: left;
        background-color: #D5D5D5;
        padding: 5px 12px;
        color: #7d7d7d;
        border-radius: 3px;
    }
    .page .page_count .paginate_button:hover{
        background-color: #89affc;
        color: #fff;
    }
    .page .page_count .paginate_active{
        margin: 0 5px;
        float: left;
        padding: 5px 12px;
        color: #fff;
        background-color: #89affc;
        border-radius: 3px;
    }
    
    .cz_clik a{display: inline-block;background: #89affc;color: #fff;padding: 3px 10px;border-radius: 3px;height: 26px;}
    .cz_clik a:hover{background: #89bffc;}
    .ui-datepicker-trigger{display: none;}
</style>
<link rel="stylesheet" href="/public/assets/sysadmin/mylzp/css/jquery-ui.css">
<script type="text/javascript" src="/public/assets/sysadmin/mylzp/js/jquery-ui.js"></script>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i> 财务管理</a></li>
            <li><a href="#">应收报表</a></li>
            <li><a href="#">应收列表</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none">应收列表</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i> 
                <b>应收列表</b>
                <a href="<?=$this->url('financial/exportReceivable?orderId='.(isset($orderId)&&!empty($orderId)?$orderId:'').'&sta='.(isset($sta)&&!empty($sta)?$sta:'').'&end='.(isset($end)&&!empty($end)?$end:'').'&qudao='.(isset($qudao)?$qudao:''))?>" style="float: right;border: 1px solid #5bc0de;background: #5bc0de;color: #fff;padding: 2px 10px;border-radius: 3px;">导出</a>
            </header>
            <div>
                <form action="<?=$this->url("financial/receivable")?>" method="get" id="formorder">
                    订单号 <input type="text" name="orderId" value="<?=isset($orderId)&&!empty($orderId)?$orderId:''?>" placeholder="订单号" />
                    离开时间 <input type="text" name="sta" class="datepickerinput" readonly="" style="background: #fff;" value="<?=isset($sta)&&!empty($sta)?$sta:''?>" placeholder="开始时间" class="input-date from" />
                    - <input type="text" name="end" class="datepickerinput" readonly="" style="background: #fff;" value="<?=isset($end)&&!empty($end)?$end:''?>" placeholder="结束时间" class="input-date to" />
                    渠道来源 <select name="qudao">
                        <option value="9999">全部</option>
                        <option value="0" <?=isset($qudao)&&$qudao==0?'selected':''?> >线下</option>
                        <?
                        if($qudaos){
                            foreach($qudaos as $k=>$v){?>
                                <option value="<?=$v['osiiId']?>" <?=isset($qudao)&&$qudao==$v['osiiId']?'selected':''?> ><?=$v['title']?></option>
                            <?}
                        }
                        ?>
                    </select>
                    <button>搜索</button>
                    <a href="<?=$this->url("financial/receivable")?>" style="font-size: 12px;color: red;margin-left: 10px;">显示全部</a>
                </form>
            </div>
            <table data-ride="datatables" class="table table-striped m-b-none dataTable" id="DataTables_Table_0" >
            <thead>
                <tr role="row">
                    <th>订单号</th>
                    <th>预订人</th>
                    <th>房型</th>
                    <th>间数</th>
                    <th>入住时间</th>
                    <th>离店时间</th>
                    <th>金额</th>
                    <th>渠道</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <?
            if(!empty($re)){
                foreach($re as $k=>$v){?>
                <tr role="row">
                    <td><?=$v['orderId']?></td>
                    <td><?=$v['name']?></td>
                    <td><?=$v['title']?></td>
                    <td><?=$v['countRoom']?></td>
                    <td><?=date('Y-m-d',$v['startDate'])?></td>
                    <td><?=date('Y-m-d',$v['endDate'])?></td>
                    <td><?=$v['price']?></td>
                    <td><?=empty($v['qudaoName'])?'线下':$v['qudaoName']?></td>
                    <td>
                        <?
                        if($v['status']==1){
                            echo '<font color="red">待入住</font>';
                        }elseif($v['status']==3){
                            echo '<font color="#1E90FF">已完成</font>';
                        }elseif($v['status']==4){
                            echo '<font color="green">已入住</font>';
                        }
                        ?>
                    </td>
                    <td class="cz_clik">
                        <?
                        if(empty($v['finStatus'])){?>
                            <a href="javascript:;" class="show_shadefrist" onclick="editReceivable('<?=$v['id']?>')">确认收款</a>
                        <?}
                        ?>
                    </td>
                </tr>
                <?}
            }else{?>
                <tr><td colspan="10">没有相关内容</td></tr>
            <?}
            ?>
            </tbody>
            </table>
            <?
            if($re){?>
                <div class="page">当前页总金额：<?=$pagePrice?>元 / 全部金额：<?=$countPrice?>元</div>
            <?}
            ?>
            <div class="page">
                <?=$pageHtml?>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<script type="text/javascript">
$(function() {
	$(".datepickerinput").datepicker({
        minDate: '',
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showOn: "both",
        showButtonPanel:true,
        duration: 100,
        onSelect: function( selectedDate ) {
            $('input[name="end"]').datepicker( "option", "minDate", selectedDate );
        }
    });
    $('.ui-datepicker-trigger').remove();
});
function editReceivable(th_key){
    $.ajax({
		type:'POST',
		url:'<?=$this->url("financial/editReceivable")?>',
		data:'id='+th_key,
		dataType:'json',
		success:function(r){
                if(r.state==0){
                    pub_alert_error(r.info,2000);
		    }else if(r.state==1){
                    pub_alert_success(r.info,2000);
                    setTimeout(function(){window.location.reload()},3000);
		    }
		},
        error:function(){
            pub_alert_error("ajax出现错误",2000);
        }
	});
}
</script>